<?php
require_once "../database/mysql.class.php";
//DAO对象，对数据库操作
//对应用户表，用户的增删改查

class saishidao{

	private $db;

	public function __construct(){
		$this->db=new mysql();
	}
	
	public function Chaxun($saishiid=null){	
		if (!isset($saishiid)){
			$sql="select * from saishi order by id;";
			return $this->db->query($sql);
		}
		else if (isset($saishiid)){
			$sql="select *  from saishi  where id like '{$saishiid}%' or  message like '{$saishiid}%' order by id;";
		    return $this->db->query($sql);
		}
		else {
			
		}
	}
	public function Tian($saishi,$img){
		if (isset($saishi)){
			$sql=" INSERT INTO saishi VALUES(null,'".$saishi."','".$img."',now(),'del');";
			return $this->db->inser($sql);
			header("location:../view/main.php?url=saishi.php");
		}
		
	}
	public function Del($delid){
		if (isset($delid)){
			//echo($delid);			
			$sql=" DELETE FROM saishi WHERE id=".$delid.";";
			return $this->db->delete($sql);
			header("location:../view/main.php?url=saishi.php");
		}
	
	}

}
?>